package org.fast.develop.logicflow.rest;

import org.fast.develop.logicflow.rest.util.VoUtil;
import org.fast.develop.logicflow.runtime.LogicRuntimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author 莫寅
 * @createTime 2022-12-22 01:51
 * @desc：
 */
@RestController
@RequestMapping("logic/execute")
public class LogicRuntimeController {

    @Autowired
    private LogicRuntimeService logicRuntimeService;

    @PostMapping("key/{key}")
    public ResponseEntity<Map> executeByKey(@PathVariable(name = "key") String key, @RequestBody Map map){
        return VoUtil.setSuccessResult(
                logicRuntimeService.startProcessInstanceByKey(key, map).getVariables()
        );
    }
}
